<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="js/jquery/jquery-1.7.1.js"></script>
    <link href="css/basic_layout.css" rel="stylesheet" type="text/css">
    <link href="common_style.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="js/authority/commonAll.js"></script>
    <script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.js"></script>
    <script type="text/javascript" src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
    <link rel="stylesheet" type="text/css" href="css/jquery.fancybox-1.3.4.css" media="screen"></link>
    <script type="text/javascript" src="js/artDialog/artDialog.js?skin=default"></script>
    <!-- Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <title>易居后台管理</title>
    <script type="text/javascript">
        $(document).ready(function(){
            /** 新增   **/
            $("#addBtn").fancybox({
                'href'  : '/house_edit',
                'width' : 733,
                'height' : 530,
                'type' : 'iframe',
                'hideOnOverlayClick' : false,
                'showCloseButton' : false,
                'onClosed' : function() {
                    window.location.href = 'sys_house.html';
                }
            });

            /**编辑   **/
            $("a.edit").fancybox({
                'width' : 733,
                'height' : 530,
                'type' : 'iframe',
                'hideOnOverlayClick' : false,
                'showCloseButton' : false,
                'onClosed' : function() {
                    window.location.href = 'sys_house.html';
                }
            });
        });

        /** 首页尾页跳转 **/
        function jumpPage(page){
            // var path = "/sys_house?page=" + page;
            // $("#submitForm").attr("action",path).submit();
            var form = document.getElementById("submitForm");
            if (page != 1) {
                document.getElementById("submitForm").action='/sys_house?page=' + '[[${pageDTO.page.getPages()}]]';
            }
            else{
                document.getElementById("submitForm").action='/sys_house?page=' + 1;
            }
            form.submit();
        }
        /** 下一页 **/
        function nextPage() {
            var form = document.getElementById("submitForm");
            document.getElementById("submitForm").action='/sys_house?page=' + '[[${pageDTO.page.getCurrent()+1}]]';
            form.submit();
        }
        /** 首页尾页跳转 **/
        function prePage() {
            var form = document.getElementById("submitForm");
            document.getElementById("submitForm").action='/sys_house?page=' + '[[${pageDTO.page.getCurrent()-1}]]';
            form.submit();
        }

        /** 输入页跳转 **/
        function jumpInputPage(totalPage){
            // 如果“跳转页数”不为空
            if($("#jumpNumTxt").val() != ''){
                var pageNum = parseInt($("#jumpNumTxt").val());
                // 如果跳转页数在不合理范围内，则置为1
                if(pageNum<1 | pageNum>totalPage){
                    art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请输入合适的页数，\n自动为您跳到首页', ok:true,});
                    pageNum = 1;
                }
                $("#submitForm").attr("action", "house_list.html?page=" + pageNum).submit();
            }else{
                // “跳转页数”为空
                art.dialog({icon:'error', title:'友情提示', drag:false, resize:false, content:'请输入合适的页数，\n自动为您跳到首页', ok:true,});
                $("#submitForm").attr("action", "house_list.html?page=" + 1).submit();
            }
        }
    </script>
    <style type="text/css">
        .alt td{ background:black !important;}
        li{
            text-decoration: none;  /*去掉前面的圆点*/
            list-style: none;
            float: left;
        }
    </style>
</head>
<body>
<form id="submitForm" name="submitForm" action="/sys_house" th:action="@{/sys_house}" method="post">
    <input type="hidden" name="allIDCheck" value="" id="allIDCheck"/>
    <input type="hidden" name="fangyuanEntity.fyXqName" value="" id="fyXqName"/>
    <div id="container">
        <div class="ui_content">
            <div class="ui_text_indent">
                <div id="box_border">
                    <div id="box_top">
                        共有房源&nbsp;&nbsp;</b><span th:text="${pageDTO.page.getTotal()}">1000</span><b>套
                    </div>
                    <div id="box_center">
                        所属城市
                            <select name="city" id="city" class="ui_select01">
                                <option value="">--请选择--</option>
                                <option value="成都" selected="selected" th:if="${select.cityContain('成都')}">成都</option>
                                <option value="成都" th:unless="${select.cityContain('成都')}">成都</option>
                                <option value="广州" selected="selected" th:if="${select.cityContain('广州')}">广州</option>
                                <option value="广州" th:unless="${select.cityContain('广州')}">广州</option>
                            </select>
                        </select>
                        审核状态
                        <select name="status" id="status" class="ui_select01">
                            <option value="">--请选择--</option>
                            <option value="0" selected="selected" th:if="${select.statusContain('0')}">待审核</option>
                            <option value="0" th:unless="${select.statusContain('0')}">待审核</option>
                            <option value="1" selected="selected" th:if="${select.statusContain('1')}">通过</option>
                            <option value="1" th:unless="${select.statusContain('1')}">通过</option>
                        </select>
                    </div>
                    <div id="box_bottom">
                        <input type="submit" value="查询" class="ui_input_btn01"/>
                        <input type="button" value="新增" class="ui_input_btn01" id="addBtn" />
                        <input type="button" value="删除" class="ui_input_btn01" onclick="batchDel();" />
                    </div>
                </div>
            </div>
        </div>
        <div class="ui_content">
            <div class="ui_tb">
                <table class="table" cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
                    <tr>
                        </th>
                        <th>标题</th>
                        <th>城市</th>
                        <th>小区</th>
                        <th>户型</th>
                        <th>房源面积</th>
                        <th>单位价格</th>
                        <th>朝向</th>
                        <th>装修</th>
                        <th>电梯</th>
                        <th>发布时间</th>
                        <th>审核状态</th>
                        <th>操作</th>
                    </tr>
                    <div class="row" th:each="house:${pageDTO.result}">
                        <tr>
                            <td style="color: black; text-decoration: none; font-weight: bold" href="#4"
                                th:text="${house.houseName}"
                                th:href="@{'/house_detail?houseId=' + ${house.houseId}}">东山国际新城H区在售AA</td>
                            <td th:text="${house.city}">GZ</td>
                            <td th:text="${house.estateName}">瑞景河畔</td>
                            <td th:text="${house.scale}">3室2厅</td>
                            <td th:text="${house.houseArea}+'平'">65.97</td>
                            <td th:text="${house.houseUnitprice}">200</td>
                            <td th:text="${house.orientation}">西南</td>
                            <td th:text="${house.decoration}">精装</td>
                            <td th:text="有电梯" th:if="${house.hasLift}"></td>
                            <td th:text="无电梯" th:unless="${house.hasLift}"></td>
                            <td th:text="${house.createTime}+'发布'">30天前发布</td>
                            <td th:text="通过" th:if="${house.status}"></td>
                            <td th:text="待审核" th:unless="${house.status}"></td>
                            <td>
                                <a  th:if="${house.status}" th:href="@{'/status_syshouse?houseId=' + ${house.houseId} + '&status='+${house.status}}"
                                class="btn btn-default">重新审核</a>
                                <a  th:unless="${house.status}" th:href="@{'/status_syshouse?houseId=' + ${house.houseId} + '&status='+${house.status}}"
                                   class="btn btn-default">通过审核</a>
                                <!--<a href="javascript:del('${house.houseId}');" th:href="@{/sys_deletehouse?houseId=' + ${house.houseId}">删除</a>-->
                                <a  class="btn btn-default" onclick="dele(this)" th:value="${house.houseId}">删除</a>
                            </td>
                        </tr>
                    </div>
                </table>
            </div>

        </div>
    </div>
</form>

<script>
    function dele(sender) {
            var msg=confirm("确定删除？");    //弹出一个窗口，询问客户信息，然后返回boolean值
            if(msg == true){
                $(document).ready(function(){
                    $.ajax({
                        type:"GET",
                        url:"/sys_deletehouse?houseId="+$(sender).attr("value"),
                        async:false,
                        success:function (data) {
                            alert("删除成功");
                            location.reload();
                        },
                        error:function (jqXHR) {
                            alert("删除失败");
                        }
                    });
                });
            }
            else  {
            }
    }
</script>
<!-- 分页条 -->
  <div class="container">
     <div class="row">
        <nav style="text-align: left" aria-label="Page navigation">
            <ul class="pagination">
                <!--<li>-->
                    <!--<button onclick="jumpNormalPage(1)">首页</button>-->
                <!--</li>-->
                <li ><a style="color: black" th:text="' 第 '+${pageDTO.page.getCurrent()}+' 页/共 '+${pageDTO.page.getPages()}+' 页 '"/></li>

                <li>
                    <button onclick="jumpPage(1)">首页</button>
                </li>
                <li th:if="${pageDTO.page.hasPrevious()}">
                    <button aria-label="Previous" onclick="prePage()">上一页</button>
                </li>
                <li th:if="${pageDTO.page.hasNext()}">
                    <button aria-label="Next" onclick="nextPage()">下一页</button>
                </li>
                <li>
                    <button onclick="jumpPage(0)">尾页</button>
                </li>
            </ul>
        </nav>
     </div>
  </div>
</body>
</html>
